Better determination of garmin waypoint shortname length. From Alan acurry.
authorrobertl <robertl@f51c46e8-681c-474f-0cfe-069cfd0219fb>
Fri, 22 Nov 2002 16:32:27 +0000 (16:32 +0000)
committerrobertl <robertl@f51c46e8-681c-474f-0cfe-069cfd0219fb>
Fri, 22 Nov 2002 16:32:27 +0000 (16:32 +0000)
gpsbabel/garmin.c

index 26c187dee1127579ceb35e7ba3c3e9a36cc4e02e..ce3049e23ecbd274a6b17e3bbe6cbc478cff9f6f 100644 (file)
@@ -154,23 +154,49 @@ data_write(void)
 
        i = 0;
        /*
-        * FIXME: Someone that knows the Garmin protocol could 
-        * do something clever here and switch on gps_save_id to 
-        * setshort_length to 
-        *      15 for  the V, 
+        * Grope the unit we're talking to to set setshort_length to 
+        *      20 for  the V, 
         *      10 for Street Pilot, Rhino, 76
         *      6 for the III, 12, emap, and etrex
         * Fortunately, getting this "wrong" only results in ugly names
         * when we're using the synthesize_shortname path.
         */
        short_length = 10;
-       switch (gps_save_id) {
-       case 155:       
-                       short_length = 20;
+
+       switch ( gps_waypt_type )       /* waypoint type as defined by jeeps */
+       {
+               case 100:       /* The GARMIN GPS Interface Specification, */
+               case 101:       /* says these waypoint types use an ident */
+               case 102:       /* length of 6.  Waypoint types 106, 108 */
+               case 103:       /* and 109 are all variable  length    */
+               case 104:
+               case 105:
+               case 107:
+               case 150:
+               case 151:
+               case 152:
+               case 154:
+               case 155:
+                       short_length = 6;
+                       break;
+               case 106:       /* Waypoint types with variable ident length */
+               case 108:       /* Need GPSr id to know the actual length */
+               case 109:                   
+                       switch ( gps_save_id )
+                       {
+                               case 130:       /* Garmin Etrex (yellow) */
+                                       short_length = 6;
+                                       break;
+                               case 155:       /* Garmin V */
+                                       short_length = 20;
+                                       break;
+                               default:
+                                       break;
+                       }
                        break;
-       default:
-                       short_length = 10;
+               default:
                        break;
+                       
        }
        setshort_length(short_length);
        setshort_mustupper(1);